var _n43;
var cc__extends = __extends;
var cc__decorate = __decorate;
var cc__importDefault = __importDefault;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $zqcc_OverallSystem = require("zqcc_OverallSystem");
var $1$TmpRope = require("TmpRope");
var c = cc__importDefault($1$TmpRope);
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var d = 7;
var def_TmpNodeManager = function (t) {
  function _ctor() {
    const instance = null !== t && t.apply(this, arguments) || this; // 使用更具描述性的变量名

    // 初始化属性
    instance.tmpsNode = null;
    instance.hideTmpNode = null;
    instance.tmpPrefab = null;
    instance.shadowNode = null;
    instance.leftNode = null;
    instance.rightNode = null;
    instance.tmpContents = new Array(d).fill(null); // 初始化临时内容数组
    instance.activeSlotCount = 5; // 设置活动槽数量

    return instance; // 返回实例
  }
  cc__extends(_ctor, t);
  _ctor.prototype.isFull = function () {
    // 检查所有活动槽是否都被填充
    for (let index = 0; index < this.activeSlotCount; index++) {
      if (!this.tmpContents[index]) {
        return false; // 如果有未填充的内容，返回 false
      }
    }
    return true; // 所有活动槽都被填充，返回 true
  };
  _ctor.prototype.getEmptyIndex = function () {
    // 检查所有活动槽是否都被填充
    for (let index = 0; index < this.activeSlotCount; index++) {
      if (!this.tmpContents[index]) {
        return index; // 如果有未填充的内容index
      }
    }
    return -1; // 所有活动槽都被填充，返回 -1
  };
  _ctor.prototype.pushObjToTemp = function (t, e) {
    if (e !== -1) { // 检查索引有效性
      const instance = cc.instantiate(this.tmpPrefab); // 实例化临时预制体
      instance.parent = this.tmpsNode.children[e]; // 设置父节点
      const component = instance.getComponent(c.default); // 获取组件
      component.setType(t.type); // 设置类型
      this.tmpContents[e] = component; // 存储到内容数组
      cc.log("放到槽里"); // 记录放置信息
      return component; // 返回组件
    }
  };
  _ctor.prototype.pushToHideTmp = function (t) {
    const instance = cc.instantiate(this.tmpPrefab); // 实例化临时预制体
    instance.parent = this.hideTmpNode; // 设置父节点
    const component = instance.getComponent(c.default); // 获取组件
    component.setType(t.type, false); // 设置类型
  };
  _ctor.prototype.onUnlockTmp = function () {
    if (this.activeSlotCount >= d) {
      $zqcc_OverallSystem.sers().uiSrv.showMessage("无法添加更多槽位"); // 显示错误信息
    } else {
      // 激活当前槽位和更新状态
      this.tmpsNode.children[this.activeSlotCount].active = true;
      this.activeSlotCount++;

      // 更新布局
      this.tmpsNode.getComponent(cc.Layout).updateLayout();

      // 更新节点位置和宽度
      this.shadowNode.width = this.tmpsNode.width + 100;
      this.leftNode.x = -this.tmpsNode.width / 2 - 15;
      this.rightNode.x = this.tmpsNode.width / 2 + 15;

      // 播放声音
      $zqcc_OverallSystem.mgrs().soundMgr.playSound("jiesuo");
    }
  };
  _ctor.prototype.clearTmp = function (t) {
    for (let index = 0; index < this.activeSlotCount; index++) {
      if (this.tmpContents[index]) {
        this.tmpContents[index].node.parent = this.hideTmpNode; // 移动节点到隐藏节点
        this.tmpContents[index] = null; // 清空内容
      }
    }

    // 如果传入的回调函数存在，则执行
    if (t) {
      t();
    }
  };
  _ctor.prototype.canClear = function () {
    return this.tmpContents.slice(0, this.activeSlotCount).some(function (t) {
      return null !== t;
    });
  };
  cc__decorate([ccp_property(cc.Node)], _ctor.prototype, "tmpsNode", undefined);
  cc__decorate([ccp_property(cc.Node)], _ctor.prototype, "hideTmpNode", undefined);
  cc__decorate([ccp_property(cc.Prefab)], _ctor.prototype, "tmpPrefab", undefined);
  cc__decorate([ccp_property(cc.Node)], _ctor.prototype, "shadowNode", undefined);
  cc__decorate([ccp_property(cc.Node)], _ctor.prototype, "leftNode", undefined);
  cc__decorate([ccp_property(cc.Node)], _ctor.prototype, "rightNode", undefined);
  return cc__decorate([ccp_ccclass], _ctor);
}(cc.Component);
exports.default = def_TmpNodeManager;